package com.leinao.media.enums;

/**
 * 海康错误码枚举类
 *
 * @author zhangyu
 * @date 2022/7/29 17:00
 */
public enum HkErrorEnum {

    NET_DVR_PASSWORD_ERROR(1, "用户名密码错误"),

    NET_DVR_NOENOUGHPRI(2, "权限不足"),

    NET_DVR_NOINIT(3, "SDK未初始化"),

    NET_DVR_CHANNEL_ERROR(4, "通道号错误"),

    NET_DVR_OVER_MAXLINK(5, "设备总的连接数超过最大"),

    NET_DVR_VERSIONNOMATCH(6, "版本不匹配"),

    NET_DVR_NETWORK_FAIL_CONNECT(7, "连接设备失败"),

    NET_DVR_NETWORK_SEND_ERROR(8, "向设备发送失败"),

    NET_DVR_NETWORK_RECV_ERROR(9, "从设备接收数据失败"),

    NET_DVR_NETWORK_RECV_TIMEOUT(10, "从设备接收数据超时"),

    NET_DVR_NETWORK_ERRORDATA(11, "传送的数据有误"),

    NET_DVR_ORDER_ERROR(12, "调用次序错误"),

    NET_DVR_OPERNOPERMIT(13, "无此权限"),

    NET_DVR_COMMANDTIMEOUT(14, "设备命令执行超时"),

    NET_DVR_ERRORSERIALPORT(15, "串口号错误"),

    NET_DVR_ERRORALARMPORT(16, "报警端口错误"),

    NET_DVR_PARAMETER_ERROR(17, "参数错误"),

    NET_DVR_CHAN_EXCEPTION(18, "设备通道处于错误状态"),

    NET_DVR_NODISK(19, "设备无硬盘"),

    NET_DVR_ERRORDISKNUM(20, "硬盘号错误"),

    NET_DVR_DISK_FULL(21, "设备硬盘满"),

    NET_DVR_DISK_ERROR(22, "设备硬盘出错"),

    NET_DVR_NOSUPPORT(23, "设备不支持"),

    NET_DVR_BUSY(24, "设备忙"),

    NET_DVR_MODIFY_FAIL(25, "设备修改不成功"),

    NET_DVR_PASSWORD_FORMAT_ERROR(26, "密码输入格式不正确"),

    NET_DVR_DISK_FORMATING(27, "硬盘正在格式化，不能启动操作"),

    NET_DVR_DVRNORESOURCE(28, "设备资源不足"),

    NET_DVR_DVROPRATEFAILED(29, "设备操作失败");


    /**
     * 错误码
     */
    private int errorCode;

    /**
     * 提示信息
     */
    private String errorMsg;

    HkErrorEnum(int errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    /**
     * 根据错误码获取错误提示信息
     *
     * @param errorCode 错误码
     * @return 错误提示信息
     */
    public static String getErrorMsgByCode(int errorCode) {
        HkErrorEnum[] hkErrorEnums = values();
        for (HkErrorEnum hkErrorEnum : hkErrorEnums) {
            if (hkErrorEnum.getErrorCode() == errorCode) {
                return hkErrorEnum.getErrorMsg();
            }
        }
        return "";
    }

}
